package com.xuzhan.meetingroom.code.room.dao;


import com.xuzhan.meetingroom.code.room.dataobject.XuzhanMeetingroom;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface XuzhanMeetingroomMapper {
    @Delete({
        "delete from xuzhan_meetingroom",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into xuzhan_meetingroom (id, num_meeting, ",
        "maxnum_meeting, location_meeting, ",
        "book_meeting, booktime_meeting, ",
        "bookman_meeting, time_record, ",
        "time_mod)",
        "values (#{id,jdbcType=INTEGER}, #{numMeeting,jdbcType=VARCHAR}, ",
        "#{maxnumMeeting,jdbcType=INTEGER}, #{locationMeeting,jdbcType=VARCHAR}, ",
        "#{bookMeeting,jdbcType=INTEGER}, #{booktimeMeeting,jdbcType=TIMESTAMP}, ",
        "#{bookmanMeeting,jdbcType=VARCHAR}, #{timeRecord,jdbcType=TIMESTAMP}, ",
        "#{timeMod,jdbcType=TIMESTAMP})"
    })
    int insert(XuzhanMeetingroom record);

    @Select({
        "select",
        "id, num_meeting, maxnum_meeting, location_meeting, book_meeting, booktime_meeting, ",
        "bookman_meeting, time_record, time_mod",
        "from xuzhan_meetingroom",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="num_meeting", property="numMeeting", jdbcType=JdbcType.VARCHAR),
        @Result(column="maxnum_meeting", property="maxnumMeeting", jdbcType=JdbcType.INTEGER),
        @Result(column="location_meeting", property="locationMeeting", jdbcType=JdbcType.VARCHAR),
        @Result(column="book_meeting", property="bookMeeting", jdbcType=JdbcType.INTEGER),
        @Result(column="booktime_meeting", property="booktimeMeeting", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="bookman_meeting", property="bookmanMeeting", jdbcType=JdbcType.VARCHAR),
        @Result(column="time_record", property="timeRecord", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="time_mod", property="timeMod", jdbcType=JdbcType.TIMESTAMP)
    })
    XuzhanMeetingroom selectByPrimaryKey(Integer id);

    @Select({
        "select",
        "id, num_meeting, maxnum_meeting, location_meeting, book_meeting, booktime_meeting, ",
        "bookman_meeting, time_record, time_mod",
        "from xuzhan_meetingroom"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="num_meeting", property="numMeeting", jdbcType=JdbcType.VARCHAR),
        @Result(column="maxnum_meeting", property="maxnumMeeting", jdbcType=JdbcType.INTEGER),
        @Result(column="location_meeting", property="locationMeeting", jdbcType=JdbcType.VARCHAR),
        @Result(column="book_meeting", property="bookMeeting", jdbcType=JdbcType.INTEGER),
        @Result(column="booktime_meeting", property="booktimeMeeting", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="bookman_meeting", property="bookmanMeeting", jdbcType=JdbcType.VARCHAR),
        @Result(column="time_record", property="timeRecord", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="time_mod", property="timeMod", jdbcType=JdbcType.TIMESTAMP)
    })
    List<XuzhanMeetingroom> selectAll();

    @Update({
        "update xuzhan_meetingroom",
        "set num_meeting = #{numMeeting,jdbcType=VARCHAR},",
          "maxnum_meeting = #{maxnumMeeting,jdbcType=INTEGER},",
          "location_meeting = #{locationMeeting,jdbcType=VARCHAR},",
          "book_meeting = #{bookMeeting,jdbcType=INTEGER},",
          "booktime_meeting = #{booktimeMeeting,jdbcType=TIMESTAMP},",
          "bookman_meeting = #{bookmanMeeting,jdbcType=VARCHAR},",
          "time_record = now(),",
          "time_mod = now()",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(XuzhanMeetingroom record);
}